﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace text.dfs
{
    public class _491
    {
        public _491()
        {
            this.temp = new List<int>();
            this.res = new List<IList<int>>();
        }
        public IList<int> temp;
        public IList<IList<int>> res;
        public IList<IList<int>> FindSubsequences(int[] nums)
        {
            dfs(0, int.MinValue, nums);
            return res;
        }
        public void dfs(int cur,int last,int[] nums)
        {
            if (cur==nums.Length)
            {
                if (temp.Count>=2)
                {
                    res.Add(new List<int>(temp) );
                }
                return;
            }
            if (nums[cur]>=last)
            {
                temp.Add(nums[cur]);
                dfs(cur+1, nums[cur], nums);
                temp.RemoveAt(temp.Count - 1);
            }
            if (nums[cur]!= last)
            {
                dfs(cur + 1, last, nums);
            }
        }
    }
}
